# coding: UTF-8
# !/usr/bin/python

import logging
import os

from .Config import Config
from .Monitor import Monitor


def main():
    logging.basicConfig(level=logging.DEBUG,
                            format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s ',
                            datefmt='%Y-%m-%d %H:%M:%S', filename='dailyCheck.log', filemode='w')
    console = logging.StreamHandler()
    console.setLevel(logging.INFO)
    formatter = logging.Formatter('%(asctime)s %(name)-12s %(levelname)-5s : %(message)s')
    console.setFormatter(formatter)
    logging.getLogger('').addHandler(console)

    config = Config()
    monitor = Monitor()
    propFile = os.path.split(os.path.realpath(__file__))[0] + "/dailyCheck.properties"
    config.setConfigFile(propFile)
    if config.display():
        print('inited')
        monitor.setConfig(config)
        monitor.start()
        
if __name__ == '__main__':
    main()
